package com.ititer.web.controller;

import org.apache.commons.lang.StringUtils;

import br.com.caelum.vraptor.Get;
import br.com.caelum.vraptor.Path;
import br.com.caelum.vraptor.Resource;

import com.ititer.enums.PublicKeys;
import com.ititer.model.Account;
import com.ititer.web.abs.AbstractController;

@Resource
@Path("/user")
public class User extends AbstractController {

	@Path("{uri}")
	@Get
	public void view(String uri) {
		if (StringUtils.isBlank(uri)) {
			controllerResult.redirectTo(Error.class).info();
			return;
		}
		Account account = accountSvc.getByUri(uri);
		if (null == account) {
			controllerResult.redirectTo(Error.class).info();
			return;
		}
		putData(PublicKeys.TargetUser.getValue(), account);
	}
}
